#include"SList.h"
void SLTPrint(SL** phead)
{
	SL* flag = *phead;
	while (flag != NULL)
	{
		printf("%d->", flag->num);
		flag = flag->SLP;
	}
	printf("NULL");
	printf("\n");

}
SL* SLPUSHNUM(SLdata x)
{
	SL* pmov = (SL*)malloc(sizeof(SL));
	if (pmov == NULL)
	{
		perror("malloc");
		return NULL;
	}
	pmov->SLP = NULL;
	pmov->num = x;
	return pmov;
}
void SLPushFront(SL** phead, SLdata x)
{
	SL* pmov = SLPUSHNUM(x);
	pmov->SLP = *phead;
	*phead = pmov;
}
void SLPushBack(SL** phead, SLdata x)
{
	SL* pmov = SLPUSHNUM(x);
	SL* flag = *phead;
	if (flag == NULL)
	{
		*phead = pmov;
	}
	else
	{
		while (flag->SLP != NULL)
		{
			flag = flag->SLP;
		}
		flag->SLP = pmov;
	}
}
void SLPopBack(SL** phead)
{
	SL* del = *phead;
	if (*phead == NULL)
	{
		assert(*phead);
	}
	if ((*phead)->SLP == NULL)
	{
		free(*phead);
		*phead = NULL;
	}
	else
	{
		while (del->SLP->SLP)
		{
			del = del->SLP;
		}
		free(del->SLP);
		(del->SLP) = NULL;
	}
}
void SLPopFront(SL** phead)
{
	if ((*phead) == NULL)
	{
		assert(*phead);
	}
	//SL* del = (*phead)->SLP;
	SL* del = (*phead);

	(*phead) = (*phead)->SLP;
	free(del);
	del = NULL;
	//free(*phead);
	//*phead = NULL;
	//*phead = del;


}